package com.gt.mapper;

import com.github.pagehelper.Page;
import com.gt.pojo.dto.BookPageQueryDTO;
import com.gt.pojo.entity.Book;
import com.gt.pojo.vo.BookVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BookMapper {

    void insert(Book book);

    Page<BookVO> pageQuery(BookPageQueryDTO bookPageQueryDTO);

    void deleteByIds(List<Long> ids);

    /**
     * 根据主键查询图书
     * @param id
     * @return
     */
    @Select("select *from library.book where id = #{id}")
    Book getById(Long id);

    void update(Book book);

    List<Book> list(Book book);

    @Select("select count(id) from library.book where category_id =#{categoryId}")
    Integer getByCategoryId(Long categoryId);

    @Delete("delete from library.book where id = #{id}")
    void deleteById(Long id);
}
